package org.dentalcard.entity;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * @user: Vladimir Chernishov
 * @date: 21.12.11
 * @time: 11:20
 */
@Entity
@Table(name = "workday")
@IdClass(WorkDayPK.class)
public class WorkDay {

    @Id
    @Temporal(TemporalType.DATE)
    private Date day;
    @Id
    private Integer userId;
    @ManyToOne
    @Fetch(FetchMode.JOIN)
    private Shift shift;

    @OneToMany
    @Fetch(FetchMode.JOIN)
    @JoinColumns({@JoinColumn(name = "workDayDay"),
            @JoinColumn(name = "workDayUserId")})
    private List<Visit> visits;
    
    public Date getDay() {
        return day;
    }

    public void setDay(Date day) {
        this.day = day;
    }

    public Shift getShift() {
        return shift;
    }

    public void setShift(Shift shift) {
        this.shift = shift;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public List<Visit> getVisits() {
        return visits;
    }

    public void setVisits(List<Visit> visits) {
        this.visits = visits;
    }
}
